@extends('Layout/personBase')

@section('title', '订单管理')

@section('css')
	<link href="{{asset('Home/css/orstyle.css')}}" rel="stylesheet" type="text/css">
@endsection


@section('right')
	@if (session('receipt'))
		<script>
			alert("{{session('receipt')}}")
		</script>
	@endif
	<!--标题 -->
	<div class="am-cf am-padding">
		<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">订单管理</strong> / <small>Order</small></div>
	</div>
	<hr/>

	<div class="am-tabs am-tabs-d2 am-margin" data-am-tabs>

		<ul class="am-avg-sm-5 am-tabs-nav am-nav am-nav-tabs">
			<li class="am-active"><a href="#tab1">所有订单</a></li>
			<li><a href="#tab2">待发货</a></li>
			<li><a href="#tab3">待收货</a></li>
			<li><a href="#tab4">待评价</a></li>
		</ul>

		<div class="am-tabs-bd">
			<div class="am-tab-panel am-fade am-in am-active" id="tab1">
				<div class="order-top">
					<div class="th th-item">
						<td class="td-inner">商品</td>
					</div>
					<div class="th th-price">
						<td class="td-inner">单价</td>
					</div>
					<div class="th th-number">
						<td class="td-inner">数量</td>
					</div>
					<div class="th th-operation">
						<td class="td-inner">商品操作</td>
					</div>
					<div class="th th-amount">
						<td class="td-inner">合计</td>
					</div>
					<div class="th th-status">
						<td class="td-inner">交易状态</td>
					</div>
					<div class="th th-change">
						<td class="td-inner">交易操作</td>
					</div>
				</div>

				<div class="order-main">
					<div class="order-list">
						@foreach ($order as $or)
						<!--交易成功-->
						 <input type="hidden" name="id" value="{{$or->id}}">
						<div class="order-status5">
							<div class="order-title">
								<div class="dd-num">订单编号：{{$or->order_number}}</div>
								<div class="dd-num"><span>成交时间：{{$or->pay_time}}</span></div>
								<em>物流状态：{{$status[$or->logistics]}}</em>
							</div>
							<div class="order-content">

								<div class="order-left">
								@foreach ($detail as $det)
									@if ($det->oid == $or->id)
									<ul class="item-list">
										<li class="td td-item">
											<div class="item-pic">
												<a href="{{url('/detail')}}/{{$det->gid}}" class="J_MakePoint">
													<img src="{{$det->goods_pic}}" class="itempic J_ItemImg">
												</a>
											</div>
											<div class="item-info">
												<div class="item-basic-info">
													<a href="#">
														<p>{{$det->goods_specification}}</p>
													</a>
												</div>
											</div>
										</li>
										<li class="td td-price">
											<div class="item-price">
												{{$det->unit_price}}
											</div>
										</li>
										<li class="td td-number">
											<div class="item-number">
												<span>×</span>{{$det->product_num}}
											</div>
										</li>
										<li class="td td-operation">
											<div class="item-operation">
												<a href="{{url('/detail')}}/{{$det->gid}}"><p>商品详情</p></a>
											</div>
										</li>
									</ul>
									@endif
								@endforeach
								</div>

								<div class="order-right">
									<li class="td td-amount">
										<div class="item-amount">
											合计：{{$or->total_money}}
										</div>
									</li>
									<div class="move-right">
										<input type="hidden" name="order_id" value="{{$or->id}}">
										<li class="td td-status">
											<div class="item-status">
												<p class="Mystatus">{{$state[$or->order_state]}}</p>
												<br>
												<p class="order-info"><a href="{{url('/Home/orderDetail')}}">订单详情</a></p>
										</li>
										@if ( $or->pay_state == '0')

										<li class="td td-change">
											<a class="am-btn am-btn-success anniu" href="{{url('/Home/pay')}}/{{$or->id}}">
												前往支付</a>
										</li>
										@endif

										@if ( $or->logistics == '2' && $or->pay_state == '1' && $or->order_state == '0')

										<li class="td td-change">
											<a class="am-btn am-btn-success anniu" href="{{url('/Home/receipt')}}/{{$or->id}}">
												确认收货</a>
										</li>
										@endif
										@if ($or->pay_state == '0')
											<li class="td td-change">
												<a class="am-btn am-btn-danger anniu" href="{{url('/Home/delete')}}/{{$or->id}}">
													取消订单</a>
											</li>
										@endif


										@if ($or->pay_state == '1' && $or->order_state == '0')
											<li class="td td-change">
												<a class="am-btn am-btn-danger anniu" href="{{url('/Home/cancel')}}/{{$or->id}}">
													申请退款</a>
											</li>
										@endif
									</div>
								</div>
							</div>
						</div>
						@endforeach
					</div>

				</div>

			</div>
			<div class="am-tab-panel am-fade" id="tab2">

				<div class="order-top">
					<div class="th th-item">
						<td class="td-inner">商品</td>
					</div>
					<div class="th th-price">
						<td class="td-inner">单价</td>
					</div>
					<div class="th th-number">
						<td class="td-inner">数量</td>
					</div>
					<div class="th th-operation">
						<td class="td-inner">商品操作</td>
					</div>
					<div class="th th-amount">
						<td class="td-inner">合计</td>
					</div>
					<div class="th th-status">
						<td class="td-inner">交易状态</td>
					</div>
					<div class="th th-change">
						<td class="td-inner">交易操作</td>
					</div>
				</div>
			@foreach ($order as $or)
				@if ($or->logistics == '0')
				<div class="order-main">
					<div class="order-list">
						<div class="order-status1">
							<div class="order-title">
								<div class="dd-num">订单编号：{{$or->order_number}}</div>
								<span>成交时间：{{$or->pay_time}}</span>
								<!--    <em>店铺：小桔灯</em>-->
							</div>
							<div class="order-content">
								<div class="order-left">
								@foreach ($detail as $det)
									@if ($det->oid == $or->id)
									<ul class="item-list">
										<li class="td td-item">
											<div class="item-pic">
												<a href="{{url('/detail')}}/{{$det->gid}}" class="J_MakePoint">
													<img src="{{$det->goods_pic}}" class="itempic J_ItemImg">
												</a>
											</div>
											<div class="item-info">
												<div class="item-basic-info">
													<a href="#">
														<p>{{$det->goods_specification}}</p>
													</a>
												</div>
											</div>
										</li>
										<li class="td td-price">
											<div class="item-price">
												{{$det->unit_price}}
											</div>
										</li>
										<li class="td td-number">
											<div class="item-number">
												<span>×</span>{{$det->product_num}}
											</div>
										</li>
										<li class="td td-operation">
											<div class="item-operation">

											</div>
										</li>
									</ul>
									@endif
								@endforeach

								</div>
								<div class="order-right">
									<li class="td td-amount">
										<div class="item-amount">
											合计：{{$or->total_money}}
										</div>
									</li>
									<div class="move-right">
										<li class="td td-status">
											<div class="item-status">
												<p class="Mystatus">{{$state[$or->order_state]}}</p>
												<p class="order-info"><a href="#">取消订单</a></p>

											</div>
										</li>
										<li class="td td-change">
											<a href="pay.html">
											<div class="am-btn am-btn-danger anniu">
												提醒发货</div></a>
										</li>
									</div>
								</div>

							</div>
						</div>
					</div>

				</div>
				@endif
			@endforeach
			</div>
			<div class="am-tab-panel am-fade" id="tab3">
				<div class="order-top">
					<div class="th th-item">
						<td class="td-inner">商品</td>
					</div>
					<div class="th th-price">
						<td class="td-inner">单1价</td>
					</div>
					<div class="th th-number">
						<td class="td-inner">数量</td>
					</div>
					<div class="th th-operation">
						<td class="td-inner">商品操作</td>
					</div>
					<div class="th th-amount">
						<td class="td-inner">合计</td>
					</div>
					<div class="th th-status">
						<td class="td-inner">交易状态</td>
					</div>
					<div class="th th-change">
						<td class="td-inner">交易操作</td>
					</div>
				</div>
			@foreach ($order as $or)
				@if ($or->logistics == '1')
				<div class="order-main">
					<div class="order-list">
						<div class="order-status2">
							<div class="order-title">
								<div class="dd-num">订单编号：{{$or->order_number}}</div>
								<span>成交时间：{{$or->pay_time}}</span>
								<!--    <em>店铺：小桔灯</em>-->
							</div>
							<div class="order-content">
								<div class="order-left">
								@foreach ($detail as $det)
									@if ($det->oid == $or->id)
									<ul class="item-list">
										<li class="td td-item">
											<div class="item-pic">
												<a href="{{url('/detail')}}/{{$det->gid}}" class="J_MakePoint">
													<img src="{{$det->goods_pic}}" class="itempic J_ItemImg">
												</a>
											</div>
											<div class="item-info">
												<div class="item-basic-info">
													<a href="#">
														<p>{{$det->goods_specification}}</p>
													</a>
												</div>
											</div>
										</li>
										<li class="td td-price">
											<div class="item-price">
												{{$det->unit_price}}
											</div>
										</li>
										<li class="td td-number">
											<div class="item-number">
												<span>×</span>{{$det->product_num}}
											</div>
										</li>
									</ul>
									@endif
								@endforeach

								</div>
								<div class="order-right">
									<li class="td td-amount">
										<div class="item-amount">
											合计：{{$or->total_money}}
										</div>
									</li>
									<div class="move-right">
										<li class="td td-status">
											<div class="item-status">
												<p class="Mystatus">{{$state[$or->order_state]}}</p>
												<p class="order-info"><a href="orderinfo.html">订单详情</a></p>
											</div>
										</li>
										<li class="td td-change">
											<div class="am-btn am-btn-danger anniu">
												确认收货</div>
										</li>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				@endif
			@endforeach
			</div>
			<div class="am-tab-panel am-fade" id="tab4">
				<div class="order-top">
					<div class="th th-item">
						<td class="td-inner">商品</td>
					</div>
					<div class="th th-price">
						<td class="td-inner">单价</td>
					</div>
					<div class="th th-number">
						<td class="td-inner">数量</td>
					</div>
					<div class="th th-operation">
						<td class="td-inner">商品操作</td>
					</div>
					<div class="th th-amount">
						<td class="td-inner">合计</td>
					</div>
					<div class="th th-status">
						<td class="td-inner">交易状态</td>
					</div>
					<div class="th th-change">
						<td class="td-inner">交易操作</td>
					</div>
				</div>

			@foreach ($order as $or)
				@if ($or->logistics == '2')
				<div class="order-main">
					<div class="order-list">
						<div class="order-status3">
							<div class="order-title">
								<div class="dd-num">订单编号：{{$or->order_number}}</div>
								<span>成交时间：{{$or->pay_time}}</span>
								<!--    <em>店铺：小桔灯</em>-->
							</div>
							<div class="order-content">
								<div class="order-left">
								@foreach ($detail as $det)
									@if ($det->oid == $or->id)
									<ul class="item-list">
										<li class="td td-item">
											<div class="item-pic">
												<a href="{{url('/detail')}}/{{$det->gid}}" class="J_MakePoint">
													<img src="{{$det->goods_pic}}" class="itempic J_ItemImg">
												</a>
											</div>
											<div class="item-info">
												<div class="item-basic-info">
													<a href="#">
														<p>{{$det->goods_specification}}</p>
													</a>
												</div>
											</div>
										</li>
										<li class="td td-price">
											<div class="item-price">
												{{$det->unit_price}}
											</div>
										</li>
										<li class="td td-number">
											<div class="item-number">
												<span>×</span>{{$det->product_num}}
											</div>
										</li>
										<li class="td td-operation">
											<div class="item-operation">
												<a href="refund.html">退款/退货</a>
											</div>
										</li>
									</ul>
									@endif
								@endforeach
								</div>
								<div class="order-right">
									<li class="td td-amount">
										<div class="item-amount">
											合计：{{$or->total_money}}
										</div>
									</li>
									<div class="move-right">
										<li class="td td-status">
											<div class="item-status">
												<p class="Mystatus">{{$state[$or->order_state]}}</p>
												<p class="order-info"><a href="orderinfo.html">订单详情</a>
											</div>
										</li>

									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				@endif
			@endforeach
			</div>

		</div>
	</div>

@endsection

@section('footer-js')
<script>
$("a[name='pay']").click(function () {
	alert(1);
	var id = $(this).parent().parent().children("input(name='order_id')").val();
	alert(id);
	var token  = "{{csrf_token()}}";
	$.ajax({
			type:'post',
			url:"{{url('/payMoney')}}",
			data: {"id":id, "_token":token},
			dataType:'json',
			success:function(data){
				if(data.code == 2000) {
					alert(data.msg);
				}else{
					alert(data.msg);
				}
			}
	});
})
</script>


@endsection
